/*
 * @(#)DerateRequestEntity.java	1.0 05/03/03
 *
 * Copyright 2004, 2005 sino, Inc. All rights reserved.
 *
 */
package com.sino.tb.confirm.entiry;

import java.sql.*;
import java.util.*;
import xpubbean.Db.*;
import com.sino.tb.funcbean.*;

public class DerateRequestEntity {
	private String seq;
	private String payerSeq;
	private String reqDate;
	private String passDate;
	private String endDate;
	private String modifyUser;
	private String modifyDate;
	private String payerName;
	private String payerCode;
	private String reduceNumberAudit;
	private String reduceNumber;
	private String freeNumberAudit;
	private String freeNumber;
	private String unitMan;
	private String unitManAudit;
	private String unitOutlay;
	private String unitOutlayAudit;
	private String unitType;
	private String unitTypeAudit;
	private DerateRequestDetailEntity[] details;
	private String beginDateAudit;
	private String sumFreeNumber;
	private String sumReduceNumber;
	private String initUnitFreeNumber;
	private String initUnitReduceNumber;

	public static DerateRequestEntity find(String key, Connection conn) {
		DerateRequestEntity dre = null;
		String sql = "SELECT t.* " +
					 "FROM   t_derate_req t " +
					 "WHERE  c_seq =  " + key + " ";
		ResultSetPlus rsp = new ResultSetPlus(sql, conn);
		if (rsp.next()) {
			dre = new DerateRequestEntity();
			dre.setSeq(rsp.getFieldStr("c_seq"));
			dre.setFreeNumber(rsp.getFieldStr("c_free_number"));
			dre.setReduceNumber(rsp.getFieldStr("c_reduce_number"));
			dre.setFreeNumberAudit(rsp.getFieldStr("c_free_number_audit"));
			dre.setReduceNumberAudit(rsp.getFieldStr("c_reduce_number_audit"));
			dre.setUnitMan(rsp.getFieldStr("c_unit_man"));
			dre.setUnitManAudit(rsp.getFieldStr("c_unit_man_audit"));
			dre.setUnitOutlay(rsp.getFieldStr("c_unit_outlay"));
			dre.setUnitOutlayAudit(rsp.getFieldStr("c_unit_outlay_audit"));
			dre.setUnitType(rsp.getFieldStr("c_unit_type"));
			dre.setUnitTypeAudit(rsp.getFieldStr("c_unit_type_audit"));
			dre.setPayerSeq(rsp.getFieldStr("c_payer_seq"));
			dre.setPayerName(rsp.getFieldStr("c_payer_name"));
			dre.setPayerCode(rsp.getFieldStr("c_payer_code"));
			dre.setBeginDateAudit(rsp.getFieldStr("c_begin_date_audit"));

			sql = "select t.*, rowid from t_derate_req_detail t where t.c_parent_seq = " + key + " AND  c_vec_select = 1 ";
			rsp = new ResultSetPlus(sql, conn);

			DerateRequestDetailEntity[] drdes = new DerateRequestDetailEntity[rsp.getMaxRcdNo()];
			int i = 0;
			while (rsp.next()) {
				drdes[i] = new DerateRequestDetailEntity();
				drdes[i].setSeq(rsp.getFieldStr("c_seq"));
				drdes[i].setVecSeq(rsp.getFieldStr("c_vec_seq"));
				drdes[i].setPayType(rsp.getFieldStr("c_pay_type"));
				drdes[i].setPayTypeAudit(rsp.getFieldStr("c_pay_type_audit"));
				drdes[i].setVecType(rsp.getFieldStr("c_vec_type"));
				drdes[i].setVecModel(rsp.getFieldStr("c_vec_model"));
				drdes[i].setVecPlate(rsp.getFieldStr("c_vec_plate"));
				drdes[i].setBodyWork(rsp.getFieldStr("c_bodywork"));
				drdes[i].setFlag(rsp.getFieldStr("c_sys_flag"));
				drdes[i].setSelected(rsp.getFieldStr("c_vec_select"));
				drdes[i].setSelectedAudit(rsp.getFieldStr("c_vec_select_audit"));
				drdes[i].setReason(rsp.getFieldStr("c_reason"));
				drdes[i].setAuditIdea(rsp.getFieldStr("c_audit_idea"));
				drdes[i].setEngine(rsp.getFieldStr("c_engine"));
				drdes[i].setPayTon(rsp.getFieldStr("c_pay_ton"));
				drdes[i].setPaySeats(rsp.getFieldStr("c_pay_seats"));
				String sqlPay = "select c_seq id, c_name||'('||c_pay*100||'%)' name from t_st_pay where c_seq <> 1001 and c_sys_flag = 1 order by id";
				String payMode = HtmlElement.getStaticFields("_980004c_pay_type_audit", sqlPay, "", Integer.parseInt(drdes[i].getPayTypeAudit()), false, conn);
				drdes[i].setPayTypeSelect(payMode);
				i++;
			}
			dre.setDetails(drdes);
		}
		return dre;
	}

	public DerateRequestEntity() {
	}

	public String getSeq() {
		return seq;
	}

	public void setSeq(String seq) {
		this.seq = seq;
	}

	public String getPayerSeq() {
		return payerSeq;
	}

	public void setPayerSeq(String payerSeq) {
		this.payerSeq = payerSeq;
	}

	public String getReqDate() {
		return reqDate;
	}

	public void setReqDate(String reqDate) {
		this.reqDate = reqDate;
	}

	public String getPassDate() {
		return passDate;
	}

	public void setPassDate(String passDate) {
		this.passDate = passDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getModifyUser() {
		return modifyUser;
	}

	public void setModifyUser(String modifyUser) {
		this.modifyUser = modifyUser;
	}

	public String getModifyDate() {
		return modifyDate;
	}

	public void setModifyDate(String modifyDate) {
		this.modifyDate = modifyDate;
	}

	public String getFreeNumber() {
		return freeNumber;
	}

	public void setFreeNumber(String freeNumber) {
		this.freeNumber = freeNumber;
	}

	public String getReduceNumber() {
		return reduceNumber;
	}

	public void setReduceNumber(String reduceNumber) {
		this.reduceNumber = reduceNumber;
	}

	public String getUnitMan() {
		return unitMan;
	}

	public void setUnitMan(String unitMan) {
		this.unitMan = unitMan;
	}

	public String getUnitOutlay() {
		return unitOutlay;
	}

	public void setUnitOutlay(String unitOutlay) {
		this.unitOutlay = unitOutlay;
	}

	public String getUnitType() {
		return unitType;
	}

	public void setUnitType(String unitType) {
		this.unitType = unitType;
	}

	public String getPayerName() {
		return payerName;
	}

	public void setPayerName(String payerName) {
		this.payerName = payerName;
	}

	public String getPayerCode() {
		return payerCode;
	}

	public void setPayerCode(String payerCode) {
		this.payerCode = payerCode;
	}

	public String getUnitManAudit() {
		return unitManAudit;
	}

	public void setUnitManAudit(String unitManAudit) {
		this.unitManAudit = unitManAudit;
	}

	public String getUnitOutlayAudit() {
		return unitOutlayAudit;
	}

	public void setUnitOutlayAudit(String unitOutlayAudit) {
		this.unitOutlayAudit = unitOutlayAudit;
	}

	public String getUnitTypeAudit() {
		return unitTypeAudit;
	}

	public void setUnitTypeAudit(String unitTypeAudit) {
		this.unitTypeAudit = unitTypeAudit;
	}

	public String getFreeNumberAudit() {
		return freeNumberAudit;
	}

	public void setFreeNumberAudit(String freeNumberAudit) {
		this.freeNumberAudit = freeNumberAudit;
	}

	public String getReduceNumberAudit() {
		return reduceNumberAudit;
	}

	public void setReduceNumberAudit(String reduceNumberAudit) {
		this.reduceNumberAudit = reduceNumberAudit;
	}

	public DerateRequestDetailEntity[] getDetails() {
		return details;
	}

	public void setDetails(DerateRequestDetailEntity[] details) {
		this.details = details;
	}

	public String getBeginDateAudit() {
		return beginDateAudit;
	}

	public void setBeginDateAudit(String beginDateAudit) {
		this.beginDateAudit = beginDateAudit;
	}

	public String getSumFreeNumber() {
		return sumFreeNumber;
	}

	public void setSumFreeNumber(String sumFreeNumber) {
		this.sumFreeNumber = sumFreeNumber;
	}

	public String getSumReduceNumber() {
		return sumReduceNumber;
	}

	public void setSumReduceNumber(String sumReduceNumber) {
		this.sumReduceNumber = sumReduceNumber;
	}

	public String getInitUnitFreeNumber() {
		return initUnitFreeNumber;
	}

	public void setInitUnitFreeNumber(String initUnitFreeNumber) {
		this.initUnitFreeNumber = initUnitFreeNumber;
	}

	public String getInitUnitReduceNumber() {
		return initUnitReduceNumber;
	}

	public void setInitUnitReduceNumber(String initUnitReduceNumber) {
		this.initUnitReduceNumber = initUnitReduceNumber;
	}

}
